/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jpao.benchmark;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author soa
 */
public class GivenStopWatchWhenCodeLastFor2sThen {
    
    @Test
    public void elapsedTimeShouldBeNear2s() throws InterruptedException {
        StopWatch sw = new StopWatch();
        Thread.sleep(2000);
        StopWatchMetric metric = sw.getMetric("test '2s'");
        assertNotNull(metric);
        System.out.println(metric.toString());
        assertTrue(metric.getElapsedTime() >= 2000000000 && metric.getElapsedTime() <= 2020000000);
    }
}
